<template>

   

    <el-card class="box-card">
      <el-row :gutter="10">
        <el-col :span="2">
          <el-select
            v-model="departmentName"
            placeholder="请选择科室"
            size="medium"
            style="width: 180px"
            @change="selectDepartment"
          >
            <el-option
              v-for="item in departmentList"
              :key="item.id"
              :label="item.name"
              :value="item.name"
            />
          </el-select>
        </el-col>
  
        <el-col :span="6">
          <el-input v-model="name" placeholder="请输入关键词"></el-input>
        </el-col>
        <div class="btn">
          <el-button type="info" @click="clear">重置</el-button>
          <el-button type="primary" @click="selectDepartment">查询</el-button>
          <el-button type="success" @click="add">新增</el-button>
        </div>
      </el-row>
    </el-card>
  
    <el-card class="box-card2">
      <el-table :data="diseaseList" style="width: 100%">
        <el-table-column align="center" prop="id" label="序号"> </el-table-column>
        <el-table-column align="center" prop="name" label="病例名称">
        </el-table-column>
  
     
  
        <el-table-column align="center" prop="doctorName" label="上传医生">
        </el-table-column>
  
      
  
        <el-table-column align="center" prop="typeString" label="类型">
        </el-table-column>
  
        <el-table-column align="center" prop="price" label="售价">
        </el-table-column>
  
        <el-table-column align="center" prop="count" label="观看次数">
        </el-table-column>

        <el-table-column align="center" prop="info" label="示例详细">
        </el-table-column>
  
        <el-table-column header-align="center" align="center" label="照片">
          <template v-slot="scope">
  
            <div v-for="item in scope.row.photoList" :key="item.id">


              <img
              :src=item
              width="100px"
              @click="handletableVideo"
            />

            </div>

          </template>
           
        </el-table-column>
  
        <el-table-column label="操作" width="350" align="center">
          <template #default="{ row }">
            <div class="mybtn">
  
              <el-button
                plain
                type="info"
                @click="goContent(row)"
                class="smallbtn"
                >内容管理
              </el-button>
  
  
              <el-button
                plain
                type="primary"
                @click="update(row)"
                class="smallbtn"
                >修改
              </el-button>
  
          
  
              <el-button
                plain
                type="success"
                @click="grounding(row)"
                class="smallbtn"
                v-if="row.courseStatus === 1"
                >上架
              </el-button>
  
              <el-button
                plain
                type="warning"
                @click="off(row)"
                class="smallbtn"
                v-if="row.courseStatus === 0"
                >下架
              </el-button>
  
              
              <el-button plain type="danger" @click="del(row)" class="smallbtn"
                >删除
              </el-button>
  
            </div>
          </template>
        </el-table-column>
  
        <template #empty>
          <el-empty description="没有数据" />
        </template>
      </el-table>
  
      <el-pagination
        class="fenye"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        v-model:current-page="pageNum"
        v-model:page-size="pageSize"
        :page-sizes="[2, 4, 6, 8]"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>
  
  </template>




<script setup>
    import {ref, reactive,onMounted} from "vue"
    import axios from "axios";
    import {useRouter} from 'vue-router'
    const name = ref("");
const departmentName = ref("");
const departmentList = ref([]);
const router = useRouter(); 


onMounted(async () => {
  const res1 = await axios.get("/department");
  departmentList.value = res1.data.data;
  getcourseList();
});

const add=()=>{
    router.push('/illUpload')
}


    const pageNum = ref(1)
    const pageSize = ref(2)
    const total = ref('')
    const diseaseList = ref([])


    onMounted( ()=>{
      getDiseaseList()
    })

    const getDiseaseList = async () => {
      const res = await axios.get('/disease/page?pageNum=' + pageNum.value + '&pageSize=' + pageSize.value + '&name=' + name.value)
      diseaseList.value = res.data.data.items;
     total.value = res.data.data.total;
    }



</script>

<style scoped>

</style>
